// componnets/notificationCard/notificationCard.js
import store from '../../modules/store'
import tool from '../../modules/tool'

Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    list: []
  },

  /**
   * 组件的方法列表
   */
  methods: {

  },

  attached() {
    let re = tool.dcJSON(store.getItem('notification'))
    if (re) {
      
      re = re.sort((a, b) => {
        if (new Date(a.time) > new Date(b.time)) return -1
        if (new Date(a.time) < new Date(b.time)) return 1
        return 0
      })
      for (let i = 0; i < re.length; i++) {
        re[i].time = tool.formatTimeNew(new Date(re[i].time))
      }
    }
    this.setData({
      list: re
    })
  }
})